package com.king.gmalllogger.controller;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @Author: KingWang
 * @Date: 2021/12/22
 * @Desc:
 **/

@Slf4j
@Controller
public class LoggerController {

    @Autowired
    private KafkaTemplate<String,String> kafkaTemplate;

    @RequestMapping("applog")
    @ResponseBody
    public String applog(@RequestBody String json){
        System.out.println(json);
        log.info(json);

        //写入kafka
        kafkaTemplate.send("ods_base_log",json);
        return "success";
    }

    @RequestMapping("test")
    @ResponseBody
    public String test(){
        System.out.println("test");
        return "success";
    }

    @RequestMapping("test2")
    @ResponseBody
    public String test2(String name){
        System.out.println(name);
        return "success";
    }
}
